home *** CD-ROM | disk | FTP | other *** search
-
- {////////////////////////////////////////////////////////////////
- // File - speaker_gui.pas
- //
- // This application plays a tone to the speaker, and is
- // controlled via a graphical user interface.
- // The speaker is accessed directly on the motherboard, using
- // WinDriver functions.
- //
- ////////////////////////////////////////////////////////////////}
-
- unit speaker_gui;
-
- interface
-
- uses
- Windows, SysUtils, Classes, Controls, Forms,
- windrvr , speaker_lib, ExtCtrls, StdCtrls;
-
- type
- TSpeaker_Form = class(TForm)
- Chime_butten: TButton;
- Tone_Butten: TButton;
- Frequency: TEdit;
- Duration: TEdit;
- freq_label: TLabel;
- dura_label: TLabel;
- Exit_Butten: TButton;
- About_Butten: TButton;
- Shape2: TShape;
- procedure Chime_buttenClick(Sender: TObject);
- procedure Tone_ButtenClick(Sender: TObject);
- procedure Exit_ButtenClick(Sender: TObject);
- procedure About_ButtenClick(Sender: TObject);
- procedure form_OnCreate(sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Speaker_Form: TSpeaker_Form;
- hSPEAKER: SPEAKER_HANDLE ;
- implementation
-
- {$R *.DFM}
-
- { play a simple chime }
- procedure TSpeaker_Form.Chime_buttenClick(Sender: TObject);
- begin
- SPEAKER_Tone(hSpeaker, 440, 400);
- SPEAKER_Tone(hSpeaker, 329, 200);
- SPEAKER_Tone(hSpeaker, 1, 10);
- SPEAKER_Tone(hSpeaker, 329, 200);
- SPEAKER_Tone(hSpeaker, 369, 400);
- SPEAKER_Tone(hSpeaker, 329, 800);
- SPEAKER_Tone(hSpeaker, 415, 400);
- SPEAKER_Tone(hSpeaker, 440, 600);
- end;
-
- { play one tone according to input from the form }
- procedure TSpeaker_Form.Tone_ButtenClick(Sender: TObject);
- var
- dwHertz: DWORD ;
- dwMilli: DWORD ;
- begin
- dwHertz:= DWORD (StrToInt(Frequency.Text));
- dwMilli:= DWORD (StrToInt(Duration.Text));
- SPEAKER_Tone(hSpeaker,dwHertz,dwMilli);
- end;
-
- procedure TSpeaker_Form.Exit_ButtenClick(Sender: TObject);
- begin
- if (SPEAKER_Open(hSPEAKER)) then
- SPEAKER_Close(hSPEAKER); { close the handle }
- Close;
- end;
-
- { shows an about box }
- procedure TSpeaker_Form.About_ButtenClick(Sender: TObject);
- begin
- application.MessageBox(
- 'Speaker Sample v1.0'#13#10#13#10'This sample accesses the on-board speaker'#13#10'through the WinDriver'#180's Delphi interface.'#13#10#13#10'Copyright (c) 2001 Jungo'
- ,PChar ('About the Speaker Sample'),MB_OK);
- end;
-
- { opens a handle to the speaker }
- procedure TSpeaker_Form.form_OnCreate(sender: TObject);
- begin
- hSPEAKER:= nil;
- if (not SPEAKER_Open(hSPEAKER)) then
- begin
- application.MessageBox(PChar (AnsiString(SPEAKER_ErrorString)),PChar ('ERROR'),MB_OK);
- halt;
- end ;
- end;
- end.
-